package com.example.myapplication
import android.media.MediaPlayer
import android.net.Uri
import android.os.Bundle
import android.widget.MediaController
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import android.widget.VideoView

class VideoPlayerActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_video_player)
//        val videoView = findViewById<VideoView>(R.id.videoView)
//        val videoPath = "https://globalimg.sucai999.com/uploadfile/20211210/267440/132836000096069452.mp4"
//        videoView.setVideoURI(Uri.parse(videoPath))
//
//        // 添加MediaController
//        val mediaController = MediaController(this)
//        videoView.setMediaController(mediaController)
//        mediaController.setAnchorView(videoView)
//
//        videoView.start() // 播放视频



        val videoUrl = intent.getStringExtra("video_url")

        // 获取VideoView
        val videoView: VideoView = findViewById(R.id.videoView)

        // 设置视频URI
        videoView.setVideoURI(Uri.parse(videoUrl))
        val mediaController = MediaController(this)
        videoView.setMediaController(mediaController)
        mediaController.setAnchorView(videoView)
        // 开始播放视频
        videoView.start()
    }

}
